package com.freewater.springboot.demo.ioc.lookupmethodinject.java8function;

import com.freewater.springboot.demo.ioc.lookupmethodinject.Command;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.function.Function;

public class CommandManager {

    private Function<String, Command> commandFunction;

    @Autowired
    public void setCommandFunction(Function<String, Command> commandFunction) {
        this.commandFunction = commandFunction;
    }

    public void process(Object commandState) {
        final Command command = this.commandFunction.apply("asyncCommand");
        command.setState(commandState);
        command.execute();
    }
}
